home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / amos / amsls396.lzh / AMOSLIST / 000024_cosmo@sci.fi_Mon Mar 4 10:12:44 1996.msg < prev    next >
Internet Message Format  |  1996-04-01  |  3KB

  1. Received: from conan.eds-ms.com (conan.eds-ms.com [204.240.136.11]) by mail1.access.digex.net (8.6.12/8.6.12) with SMTP id KAA19113;  for <mcox@access.digex.net> ; Mon, 4 Mar 1996 10:12:42 -0500
  2. Received: from r2d2.sci.fi by conan.eds-ms.com (5.x/SMI-SVR4)
  3.     id AA21606; Mon, 4 Mar 1996 09:19:49 -0500
  4. Received: from sci.fi (cosmo@borg [194.215.80.5]) by r2d2.sci.fi (8.6.12/8.6.11) with ESMTP id QAA02024; Mon, 4 Mar 1996 16:19:09 +0200
  5. Received: (cosmo@localhost) by sci.fi (8.6.12/8.6.4) id QAA12288; Mon, 4 Mar 1996 16:19:07 +0200
  6. Date: Mon, 4 Mar 1996 16:19:07 +0200 (EET)
  7. From: Ville Ranki <cosmo@sci.fi>
  8. X-Sender: cosmo@borg
  9. To: Robert Currie <currie@cpsc.ucalgary.ca>
  10. Cc: amos-list@conan.eds-ms.com
  11. Subject: Re: Clipped line
  12. In-Reply-To: <199603040827.BAA14611@fsf.cpsc.ucalgary.ca>
  13. Message-Id: <Pine.sol.3.90.960304160812.11131D-100000@borg>
  14. Organization: Scifi Communications International Oy
  15. Mime-Version: 1.0
  16. Content-Type: TEXT/PLAIN; charset=US-ASCII
  17. Status: RO
  18. X-Status: 
  19.  
  20. On Mon, 4 Mar 1996, Robert Currie wrote:
  21.  
  22. > You should try to implement a binary search of coordinates along the line 
  23. > in question. The routine should follow this method:
  24. > Check boundary conditions-- If its totally in, draw the line
  25. >                             If its totally out, discard it
  26. >       
  27. > If one endpoint is in then
  28. > Recursively discard segments of the line--
  29. >   (Can be implemented with a while loop)
  30. >   Find the midpoint of the line inx,iny-->outx,outy
  31. >   Is that point within the clip region?
  32. >      If it is, temparily adopt that as the new 'in' point
  33. >      If it isn't then adopt it as the new 'out' point
  34. >   Recurse until one of the coordinates equals one of the clip coordinates
  35. > Draw line using the final point 
  36.  
  37. This might help, if i can make it fast enough.
  38.  
  39. > If both endpoints are out but a line segment is in then
  40. >   Binary search the line to find a point that resides in the clip zone
  41. >   Find endpoints using a technique similar to the one above
  42. >   Draw the two lines
  43. > Exit
  44.  
  45. I'm doing this in Amos and for line vector graphics, so it should be 
  46. _fast_.
  47.  
  48. > Either that or you can simply write your own line routine and not plot points
  49. > that occur outside of the clip plane. There are several good line algorithms
  50. > that can be used such as Bresenhams algorithm for line drawing which only
  51. > uses incremetal integer calculations.
  52.  
  53. Not in amos :(
  54.  
  55. There is a formula doing the clipping perfectly, but i can't get it 
  56. working in all corners of screen. Here's a quick ascii version:
  57.  
  58. (bottom of the screen)
  59.  
  60.        . (X1,Y1)
  61.     ^  ^\
  62.     | A| \
  63.     |  V  \ XL
  64. ----|--<--->---------------------------(320,256)
  65.    C|    B  \
  66.     |        \ 
  67.     |         \.(X2,Y2)
  68.     V<--------->          
  69.           D
  70.  
  71. A=256-Y1
  72. D=X2-X1
  73. C=Y2-Y1
  74.  
  75. B=(A*D)/C
  76.  
  77. XL=X3+B
  78. Y=256
  79.  
  80. Clipped end point=(XL,Y)
  81.  
  82.  
  83.  
  84. ,----- -- -         - -- ------- --------.-S-- ---------------.
  85. |    <: Ville Ranki :>               ::::| N Ville Ranki   :::|
  86. :  - E-Mail: cosmo@sci.fi              ::: A Mansikkakuja 6  :|
  87. :  - WWW   : http://www.sci.fi/~cosmo/  :: I 33960 Pirkkala  :|
  88. |  - IRC   : CoSMo - #Amiga             .| L    Finland      .|
  89. `-------------- -- -         - -- -------'-------------- --- -'
  90.